package com.bt.dmdb.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

@Entity
@Table(name = "document")
@SuppressWarnings("serial")
public class Document implements java.io.Serializable  {

	 private Long id;
	 private String name;
	 private String category;
	 //private Set<CustomerDetails> customers = new HashSet<CustomerDetails>(0);
	 private Set<CustomerDocument> customerDocuments = new HashSet<CustomerDocument>(0);
	 private String rules;
	 
	 
	public Document() {
	}
	public Document(Long id) {
	        this.id = id;
	}

    public Document(Long id, String name) {
	        this.id = id;
	        this.name = name;
	}
	public Document(Long id, String name, String category,
			//Set<CustomerDetails> customers,
			Set<CustomerDocument> customerDocuments) {
		super();
		this.id = id;
		this.name = name;
		this.category = category;
	//	this.customers = customers;
		this.customerDocuments = customerDocuments;
	}
	
	@Id
    @GeneratedValue(generator = "documentIG", strategy = GenerationType.TABLE)
    @TableGenerator(name = "documentIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "Document", allocationSize = 10, valueColumnName = "next_hi_value")
   	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	@Column(name = "name", nullable = false, length = 500)
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name = "category", nullable = false, length = 45)
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	
	/*@ManyToMany(fetch = FetchType.LAZY, mappedBy = "customerDocuments")
	public Set<CustomerDetails> getCustomers() {
		return customers;
	}
	public void setCustomers(Set<CustomerDetails> customers) {
		this.customers = customers;
	}*/
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "doc")
	public Set<CustomerDocument> getCustomerDocuments() {
		return customerDocuments;
	}
	public void setCustomerDocuments(Set<CustomerDocument> customerDocuments) {
		this.customerDocuments = customerDocuments;
	}
	
	@Column(name = "rules", nullable = true, length = 500)
	public String getRules() {
		return rules;
	}
	
	public void setRules(String rules) {
		this.rules = rules;
	}
	
}
